package JavaSE.d2;
/*
	编程一个学生类，封装姓名、年龄、城市、学校四个属性
在测试类的main方法中，创建两个学生类对象，为属性赋值，并输出。
 */
public class Test13 {
    public static void main(String[] args) {
        Student student = new Student("关云长",22,"运城","太原学院");
        Student student2 = new Student();
        student2.setName("司马懿");
        student2.setAge(999);
        student2.setCity("魏国");
        student2.setSchool("帝国军事学院");
        System.out.println(student.toString());
        System.out.println(student2.name+"\n"+student2.getAge()+"\n"+student2.getCity()+"\n"+student2.getSchool());
    }
}

class Student{
    String name;
    private int age;
    private String city;
    private String school;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public Student() {
    }
    public Student(String name, int age, String city, String school) {
        this.name = name;
        this.age = age;
        this.city = city;
        this.school = school;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", city='" + city + '\'' +
                ", school='" + school + '\'' +
                '}';
    }
}